package edu.tms.dao;

import java.util.List;
import java.util.Map;

import edu.tms.bean.ExamType;
import edu.tms.crud.JdbcUtil;
import edu.tms.dao.common.CommnonDao;

/**
 * 考试类型表
 * @author Administrator
 *
 */
@SuppressWarnings("rawtypes")
public class ExamTypeDaoImp implements CommnonDao{
	/**
	 * 保存内容
	 * 不用添加
	 * @param value
	 * @return 
	 * @throws Exception
	 */
	@Override
	public long save(Object value) throws Exception {
		return 0;
	}
	/**
	 * 修改内容
	 * 不用修改
	 * @param value
	 * @throws Exception
	 */
	@Override
	public int update(Object value) throws Exception {
		return 0;
	}
	/**
	 * 删除内容
	 * 不能删除
	 * 考试信息表t_exam
	 * @param value
	 * @throws Exception
	 */
	@Override
	public int delete(Object value) throws Exception {
		return 0;
	}
	/**
	 * 查找所有的内容
	 * 考试信息表t_exam
	 * @param pageNo 第几页
	 * @param pageSize 每页数字
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<ExamType> findAll(int pageNo, int pageSize) throws Exception {
		String sql="select * from t_exam_type limit ?,?";
		return (List<ExamType>)JdbcUtil.query(ExamType.class, sql, pageNo,pageSize);
	}
	
	/**
	 * 查找所有的内容
	 * 考试信息表t_exam
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<ExamType> findAll() throws Exception {
		String sql="select * from t_exam_type;";
		List<ExamType> t=JdbcUtil.query(ExamType.class, sql);
		return t;
	}
	/**
	 * 查找单一实体
	 * 考试信息表t_exam
	 * @param Key
	 * @throws Exception
	 */
	@Override
	public ExamType findByKey(Object Key) throws Exception {
		return (ExamType) JdbcUtil.uniqueBean(ExamType.class,
				"select * from t_exam_type where exam_type_id = ? or exam_type_name = ?",
					Key, Key);
	}
	
	/**
	 * 根据条件查看更多
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List findAll(Object key, int pageNo, int pageSize) throws Exception {
		String sql="select * from t_exam_type where exam_type_state=? limit ?,?";
		return (List<ExamType>)JdbcUtil.query(ExamType.class, sql,key,pageNo,pageSize);
	}
	
	/**
	 * String 对应  数据库 列名（comment)
	 * Object 对应相应列名值
	 * 返回的是所查找的类中的数据。方便EXCEL导出
	 */
	@Override
	public List<Map<String,Object>> getMapList() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	
	@SuppressWarnings("unchecked")
	public List<ExamType> examtype(String className) throws Exception{
			String sql="SELECT DISTINCT ty.`exam_type_name`FROM t_exam_type ty,t_exam te,t_grade tg," 
					  +"t_student ts WHERE ty.`exam_type_name`=te.`exam_type_name`AND "
					  +"te.`exam_id`=tg.`exam_id` AND tg.`stu_id`=ts.`stu_id` AND ts.`stu_class_name`=?"; 
			return JdbcUtil.query(ExamType.class, sql,className);
	}
	
}
